package cn.aulang.study.ai.client.controller;

import org.springframework.ai.chat.client.ChatClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

/**
 * 时间
 *
 * @author Aulang
 */
@RestController
public class TimeController {

    private final ChatClient chatClient;

    public TimeController(@Autowired ChatClient chatClient) {
        this.chatClient = chatClient;
    }

    @GetMapping("/current-date")
    public Flux<String> currentDate() {
        return chatClient.prompt("获取当前日期").stream().content();
    }

    @GetMapping("/current-time")
    public Flux<String> currentTime() {
        return chatClient.prompt("获取当前时间").stream().content();
    }
}
